all: install main

include $(GOROOT)/src/Make.$(GOARCH)


DIRS=\
	mat\
	highgui\
	kernel\
	spring\
	nbody\
	imageserver\

NOTEST=\
	highgui\
	kernel\
	spring\
	nbody\

TEST=\
	$(filter-out $(NOTEST),$(DIRS))

clean.dirs: $(addsuffix .clean, $(DIRS))
install.dirs: $(addsuffix .install, $(DIRS))
nuke.dirs: $(addsuffix .nuke, $(DIRS))
test.dirs: $(addsuffix .test, $(TEST))

%.clean:
	+cd $* && gomake clean

%.install:
	+cd $* && gomake install

%.nuke:
	+cd $* && gomake nuke

%.test:
	+cd $* && gomake test

clean: clean.dirs

install: install.dirs

test:   test.dirs

nuke: nuke.dirs
	rm -rf "$(GOROOT)"/pkg/*

spring-mass: install spring.go main.go
	$(GC) spring.go main.go
	$(LD) -o $@ spring.$O
	
pso: install pso.go
	$(GC) pso.go
	$(LD) -o $@ pso.$O
	
pso-cell: install pso-cell.go
	$(GC) pso-cell.go
	$(LD) -o $@ pso-cell.$O

